import { getReDetail} from '../../api/index.js'

// pages/recommendDetail/recommendDetail.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    searchText: '',
    list: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  onShow: function() {
    this.getReDetail()
  },

  onSearch: function(e) {
    const {detail:{searchText}} = e

    this.setData({
      searchText
    })
  },

  getReDetail: function(params) {
    getReDetail({
      ...params,
      page: 1,
      page_size: 10
    })
    .then(res => {
      this.setData({
        list: res.data
      })
      console.log(res, '获取推荐明细')
    })
    .catch(e => {
      console.log(e, '推荐明细')
    })
  },

  searchChange: function(e) {
    const {detail:{}} = e
    this.getReDetail()
  },

  onPullDownRefresh(pageOption) {
    console.log(pageOption, 'render page option')
  }
})